﻿using System;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace EuphoricEngine3D.Helpers
{
    public static class KeyboardHelper
    {
        public static string GetString(Keys key, bool shift, bool capslock)
        {
            bool Capital = shift || capslock;

            switch (key)
            {
                case Keys.Space:
                    return " ";
                case Keys.Add:
                    return "+";
                case Keys.Subtract:
                    return "-";
                case Keys.Multiply:
                    return "*";
                case Keys.Divide:
                    return "\\";
                case Keys.Decimal:
                    return ".";
                case Keys.OemBackslash:
                    return (Capital) ? "|" : "\\";
                case Keys.OemCloseBrackets:
                    return (Capital) ? "}" : "]";
                case Keys.OemComma:
                    return (Capital) ? "<" : ",";
                case Keys.OemMinus:
                    return (Capital) ? "_" : "-";
                case Keys.OemOpenBrackets:
                    return (Capital) ? "{" : "[";
                case Keys.OemPeriod:
                    return (Capital) ? ">" : ".";
                case Keys.OemPipe:
                    return (Capital) ? "|" : "\\";
                case Keys.OemPlus:
                    return (Capital) ? "+" : "=";
                case Keys.OemQuestion:
                    return (Capital) ? "?" : "/";
                case Keys.OemQuotes:
                    return (Capital) ? "\"" : "'";
                case Keys.OemSemicolon:
                    return (Capital) ? ":" : ";";
                case Keys.OemTilde:
                    return (Capital) ? "~" : "#";
                default:
                    string k = key.ToString();
                    if (k.Length == 1)
                        return Capital ? k[0].ToString().ToUpper() : k[0].ToString().ToLower();
                    else if (k.Length == 2 && k.StartsWith("D"))
                    {
                        if (Capital)
                        {
                            switch (int.Parse(k.Substring(1, 1)))
                            {
                                case 0:
                                    return ")";
                                case 1:
                                    return "!";
                                case 2:
                                    return "\"";
                                case 3:
                                    return "£";
                                case 4:
                                    return "$";
                                case 5:
                                    return "%";
                                case 6:
                                    return "^";
                                case 7:
                                    return "&";
                                case 8:
                                    return "*";
                                case 9:
                                    return "(";
                                default:
                                    return string.Empty;
                            }
                        }
                        else
                            return k[0].ToString();
                    }
                    else
                        return string.Empty;
            }
        }
    }
}
